#pragma once
#include "lib\TCollection.h"
#include "model\BaseModel.h"
#include "lib\pointcalc\PointCalculator.h"
#include "model\Division.h"
#include <string>
#include <set>
#include <utility>
#include <iterator>

class Division;

class Sport : public BaseModel {
public: 
  typedef TCollection<Division>::IterBoolPair IterBoolPair;

  // Constructors and deconstructor
  Sport();
  explicit Sport(std::string name);
  explicit Sport(std::string name, int tabletype);
  virtual ~Sport() { }

  // Mutators
  void set_name(std::string name) {
    name_ = name;
  }

  void set_tabletype(int type) {
    tabletype_ = static_cast<PointCalculator::TableType>(type);
  }
 
  // Accessors
  std::string name() const;
  int tabletype() const;
  

  // Division related functions
  IterBoolPair AddDivision(Division& division);
  IterBoolPair FindDivision(const Division& div) const;
  TCollection<Division>::CollectionPair GetDivisions() const;
  int NumDivisions() const;
  void DeleteDivision(std::set<Division>::iterator iter);

  
  // Comparison operators
  int operator==(const Sport &sport) const;
  bool operator<(const Sport &sport) const;
  
  // model validation function
  virtual bool Validate();



private:
  std::string NameChars();

  // Friendly input and output operators
  friend std::ostream& operator<<(std::ostream& out, const Sport& sport);
  friend std::istream& operator>>(std::istream& in,  Sport& sport);

  std::string name_;
  TCollection<Division> divisions_;
  PointCalculator::TableType tabletype_;
  PointCalculator *pointcalc_;
  
};